<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::group(array('namespace' => 'backend', 'prefix' => 'backend'), function() {
	Route::get('/login', 'LoginController@login')->name('login');
	Route::post('/login', 'LoginController@attempt')->name('attempt');
	Route::get('/logout', 'LoginController@logout')->name('logout');
});

Route::group(array('namespace' => 'backend', 'prefix' => 'backend', 'middleware' => 'auth:admin'), function() {
	Route::get('/password/reset', 'PasswordController@disp');
	Route::post('/password/reset', 'PasswordController@reset');

	Route::get('/', 'DefaultController@index');
	Route::resource('categories', 'CategoryController', ['only' => ['index', 'create', 'store', 'destroy']]);
	Route::resource('books', 'BookController', ['only' => ['index', 'destroy', 'edit', 'update']]);
	Route::resource('books.sections', 'SectionController', ['only' => ['index', 'show', 'edit', 'update']]);
	Route::resource('operations', 'OperationController', ['only' => ['index']]);
	Route::delete('/operations/destroy-all', 'OperationController@destroyAll');
	Route::resource('links', 'LinkController');
	Route::resource('administrator', 'AdministratorController');
	Route::resource('members', 'MemberController');
	Route::any('/recover', 'BookController@recover');
	Route::resource('feedbacks', 'FeedbackController', ['only' => ['index', 'destroy']]);
	Route::post('/feedbacks/{id}/finished', 'FeedbackController@finished');
});

Route::group(array('namespace' => 'mobile', 'prefix' => 'mobile'), function() {
	Route::get('/', 'DefaultController@index');
	Route::get('/categories/{id}', 'CategoryController@show');
	Route::resource('books', 'BookController', ['only' => ['show']]);
	Route::get('/books/{id}/sections', 'BookController@sections');
// 	Route::get('/books/{id}/download', 'BookController@download');
	Route::get('/search', 'DefaultController@search');
	Route::get('/history', 'DefaultController@history');
	Route::get('/books/{bookId}/sections/{order}', 'SectionController@show');
});

Route::group(array('namespace' => 'desktop\publics', 'middleware' => array('mobile_detect')), function() {
	Route::get('/login', 'LoginController@index');
	Route::post('/login', 'LoginController@attempt');
	Route::get('/logout', 'LoginController@logout');
	Route::get('/register', 'RegisterController@index');
	Route::post('/register', 'RegisterController@attempt');
	
	Route::get('/', 'DefaultController@index');
	Route::get('/history', 'DefaultController@history');
	Route::get('/search', 'DefaultController@search');
	Route::resource('books', 'BookController', ['only' => ['show']]);
// 	Route::get('/books/{id}/download', 'BookController@download');
	Route::resource('categories', 'CategoryController', ['only' => ['show']]);
	Route::get('/books/{bookId}/sections/{order}', 'SectionController@show');
	Route::post('/feedbacks', 'FeedbackController@store');
});

Route::group(array('namespace' => 'desktop\cs', 'prefix' => 'cs', 'middleware' => array('mobile_detect', 'auth')), function () {
	Route::get('/', 'DefaultController@index');
	Route::resource('/bookshelves', 'BookshelfController', ['only' => ['index', 'store', 'destroy']]);
	Route::get('/comments', 'CommentController@index');
	Route::get('/feedbacks', 'FeedbackController@index');
});